﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Pg.BioMedics.SDR.Entities;
using Pg.BioMedics.SDR.Entities.Codes;

namespace Pg.BioMedics.SDR.Caching
{
    /// <summary>
    /// Provides strongly typed cache for Token entities
    /// </summary>
    public class TokenCache : BaseCache<Token>
    {
        #region Constructors

        /// <summary>
        /// Creates instance of TokenCache with the given strategy.
        /// </summary>
        /// <param name="cachingStrategy">Caqching strategy</param>
        internal TokenCache(ICachingStrategy<Token> cachingStrategy)
            : base(cachingStrategy) { }

        #endregion

        #region Overriden methods

        /// <summary>
        /// Gets a Token key utilized as a key in the cache
        /// </summary>
        /// <param name="item">Token instance</param>
        /// <returns>Token key</returns>
        public override string GetKey(Token item)
        {
            return item.Id.HasValue ? item.Id.Value.ToString() : null;
        }

        #endregion        
    }
}
